<template>
	<web-view :src="url" bindmessage="getMessage"></web-view>
</template>

<script>
	export default {
		data() {
			return {
				baseUrl: 'https://qfck70.kuaishang.cn/bs/im.htm?cas=3513___963763&fi=4005&ism=1',
				url: ''
			}
		},
		onLoad(options) {
			let goods_name = options.goods_name || ''
			let goods_image = options.goods_image || ''
			let goods_price = options.goods_price || ''
			let goods_no = options.goods_no || ''
			this.start(goods_name, goods_image, goods_price, goods_no)
		},
		methods: {
			start(goods_name, goods_image, goods_price, goods_no) {
				let user = uni.getStorageSync('userBaseInfo')
				console.log(user)
				let customData = {}
				let ecv = {
					"vipNo": user ? user.spread_code : '', // 必填 商城会员唯一标识
					"vipName": user ? user.name : '', // 必填 商城会员名称
					"regTime": user.create_time, // 必填 商城会员名称
					"lastLoginTime": user.last_time, // 必填 商城会员名称
					"isComplete": "true"
				}
				
				if(user){
					customData.ecv = ecv
				}
				let ecg = {
					"goodsNo": goods_no, // 必填 商城商品唯一标识
					"goodsName": goods_name, // 必填 商城商品名称
					"goodsPrice": goods_price, // 必填 商城商品价格
					"goodsPhoto": goods_image, // 必填 商城商品图片地址
					"isComplete": "true",
					"attribute": ""
				}
				if (goods_name) {
					customData.ecg = ecg
				}
				let ecInfo = JSON.stringify(customData)
				console.log(ecInfo)
				this.url = this.baseUrl + '&ecInfo=' + encodeURIComponent(ecInfo)
			}
		}
	}
</script>

<style>

</style>
